package com.lazydong.apiforward.client.gui.enums;

import com.lazydong.apiforward.client.framework.PageInfo;

import java.io.File;

public enum PageInfoEnum implements PageInfo {
    AppMain("主界面", "AppMainPage.json", true),
    LOG_SHOW("路由转发日志", null, true),
    API_ROUTE("API路由", "api_route.json", true),
    USER_PROXY("用户代理", "user_proxy.json", true),
    ;

    public final String tabName;
    public final String configFile;
    public final boolean hasRunData;

    PageInfoEnum(String tabName, String configFile, boolean hasRunData) {
        this.tabName = tabName;
        this.configFile = configFile;
        this.hasRunData = hasRunData;
    }

    @Override
    public String getTabName() {
        return tabName;
    }

    @Override
    public String configFilePath() {
        return PathEnum.CONF.path + File.separator + configFile;
    }

    @Override
    public String runDataPath() {
        if (!hasRunData) {
            throw new RuntimeException("当前Page没有运行数据");
        }
        return PathEnum.DATA.path + File.separator + configFile;
    }
}
